<div class="layui-fluid">
      <div class="layui-row">

      <form class="layui-form" action="">
        <div class="layui-form-item">
        <div class="layui-input-inline">
          <input type="number" placeholder="价格" autocomplete="off" value="0" class="layui-input" id="specs_price">
        </div>
        <div class="layui-input-inline">
          <input type="number" id="specs_num"  placeholder="库存" value="0" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-input-inline">
          <button type="button" id="all" class="layui-btn">批量填充</button>
        </div>
      </div>
        <table class="layui-table">
          <colgroup>
            <col width="150">
            <col width="200">
            <col>
          </colgroup>
          <thead>
            <tr>
              {volist name="temp6" id="item"}
              <th>{$item}</th>
              {/volist}
              <th>价格</th>
              <th>库存</th>
            </tr> 
          </thead>
          <tbody>
            {foreach name="temp4" item="vo" key="k" }
            <tr>
              {volist name="vo" id="item"}
              <td>{$temp5[$item]['specs_value']}</td>
              {/volist}
              <th><input type="text" name="specs_price[{$k}]" class="layui-input specs_price" value="{$temp7[$k]['specs_price']?$temp7[$k]['specs_price']:'0'}"></th>
              <th><input type="text" name="specs_num[{$k}]" class="layui-input specs_num" value="{$temp7[$k]['specs_num']?$temp7[$k]['specs_num']:'0'}"></th>
              <input type="hidden" name="specs_name[{$k}]" value="{volist name='vo' id='item'}{$temp5[$item]['specs_value']}
              {/volist}">
            </tr>
            {/foreach}
            
          </tbody>
        </table>
         <input type="hidden" name="goods_id" value="{$goods_id}">
        <button class="layui-btn" lay-submit lay-filter="add">发布</button>
      </form>
    </div>
  </div>
 <style>
   body{
    background: #fff;
   }
 </style>

<script>
//Demo
layui.use(['form','layedit','upload'], function(){
  var form = layui.form;
  var upload = layui.upload;
  var layedit = layui.layedit;

  $('#all').click(function(event) {

     var specs_price = $('#specs_price').val();
     var specs_num = $('#specs_num').val();

     $('.specs_price').val(specs_price);
     $('.specs_num').val(specs_num);
  });
  //监听提交
  form.on('submit(add)', function(data){


    $.post('{:url('admin/goods/add_sku_list')}', data.field, function(data, textStatus, xhr) {
      // if(data.code){
      //   layer.alert(data.msg, {icon: 6},function(){
      //     xadmin.close();
      //     parent.location.reload();
      //   });
      // }else{
      //   layer.msg(data.msg, function(){});
      // }
      /*optional stuff to do after success */
    });
    console.log(data.field)
    // layer.msg(JSON.stringify(data.fsield));
    return false;
  });
});

function del_attr(obj) {
  $(obj).parents('.layui-form-item').remove();
}
</script>
      